package list;

import java.util.HashMap;
import java.util.UUID;

public class Demo07 {
    public static void main(String[] args) {
        HashMap<String, Integer> map1 = new HashMap<>();
        HashMap<String, Integer> map2 = new HashMap<>();
        HashMap<String, Integer> map3 = new HashMap<>();
        String key=null; //3个集合中都有的key
        for(int i=0; i<1000000; i++){
            String uuid = UUID.randomUUID().toString();
            if (i==9999) key = uuid;
            if (i<10000) map1.put(uuid, i);
            if (i<100000) map2.put(uuid, i);
            map3.put(uuid, i);
        }
        long t1 = System.nanoTime();
        Integer value1 = map1.get(key);
        long t2 = System.nanoTime();
        Integer value2 = map2.get(key);
        long t3 = System.nanoTime();
        Integer value3 = map3.get(key);
        long t4 = System.nanoTime();
        System.out.println("map1.get("+key+")="+value1+" 耗时:"+(t2-t1));
        System.out.println("map2.get("+key+")="+value2+" 耗时:"+(t3-t2));
        System.out.println("map3.get("+key+")="+value3+" 耗时:"+(t4-t3));
    }
}
